package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/8/17 21:50
 * @description：https://leetcode-cn.com/problems/student-attendance-record-i/
 */
public class 学生出勤记录I {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.checkRecord("ALLAPPL"));
    }

    class Solution {
        public boolean checkRecord(String s) {
            int countA = 0, countL = 0, countP = 0;
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if (ch == 'A') {
                    countA++;
                    countL = 0;
                    countP = 0;
                } else if (ch == 'L') {
                    countL++;
                    countP = 0;
                } else {
                    countP++;
                    countL = 0;
                }
                if (countA >= 2 || countL >= 3) {
                    return false;
                }
            }
            return true;
        }
    }

}
